<?php

class why_tutorland extends Controller {

	function Welcome()
	{
		parent::Controller();	
	}
	
	function index()
	{
		$this->load->model('filemanagementmodel');
	    $data['header_tel'] = $this->filemanagementmodel->getByPostion('header_tel');
	    $data['footer_address'] = $this->filemanagementmodel->getByPostion('footer_add1');
	    $data['why_detail'] = $this->filemanagementmodel->getByPostion('why_detail');
	    
		$this->load->view('f_header', $data);
		$this->load->view('f_why_tutorland', $data);
		$this->load->view('f_footer', $data);
	}
	
	function edit()
	{
		if ($this->session->userdata('logged_in') != TRUE)
	    {
	        redirect('login/index');
	    }
		 
	    $this->load->model('filemanagementmodel');
	    $data['why_detail'] = $this->filemanagementmodel->getByPostion('why_detail');
	    
		$this->load->view('header');
		$this->load->view('f_why_tutorland_edit', $data);
		$this->load->view('footer');
	}
	
	function save()
	{
	 	if ($this->session->userdata('logged_in') != TRUE)
	    {
	        redirect('login/index');
	    }
	    
	    
	    $this->load->model('filemanagementmodel');
	    $data['position'] = 'why_detail';
	    $data['longd'] = $this->input->post('txtDetail');
		$this->filemanagementmodel->update($data);
		
		$this->msg['msg'] = "บันทึกข้อมูลเรียบร้อย";
		$data['why_detail'] = $this->filemanagementmodel->getByPostion('why_detail');
		 
		$this->load->view('header');
		$this->load->view('f_why_tutorland_edit', $data);
		$this->load->view('footer', $this->msg);
	}
}

?>